package org.etherframework.tests.features.command.commands
{
	import flash.events.Event;
	
	import org.etherframework.controller.IGestureCommand;
	import org.etherframework.controller.InitializableCommand;
	import org.etherframework.tests.features.command.events.UpdateItemEvent;
	import org.etherframework.tests.features.command.models.Item;
	
	public class UpdateItemCommand extends InitializableCommand implements IGestureCommand
	{
		public static var executed:Vector.<UpdateItemCommand> = new Vector.<UpdateItemCommand>();
		
		public var wasExecutedWithItem:Item;
		private var _event:UpdateItemEvent;
		private var _item:Item;
		
		public function UpdateItemCommand()
		{
			super();
		}
		
		public function initialize(item:Item):void
		{
			_item = item;
			markAsInitialized();
		}
		
		override public function execute():void
		{
			wasExecutedWithItem = _item;
			executed.push(this);
		}
		
		public function get event():Event { return _event; }
		public function set event(value:Event):void
		{
			_event = UpdateItemEvent(value);
			initialize(_event.item);
		}
	}
}